
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:self32/page/register_select_page.dart';
import '../main.dart';
import '../util/timer_manager.dart';
import '../widget/app_bar.dart';
import '../widget/custom_floating_action_button_location.dart';
import '../widget/float_button.dart';
import 'register_page.dart';


class RegisterTip extends StatefulWidget {
  const RegisterTip({Key? key}) : super(key: key);

  @override
  State<RegisterTip> createState() => _RegisterTipState();
}

class _RegisterTipState extends State<RegisterTip> {


  @override
  initState() {
    super.initState();

    WidgetsBinding.instance.addPostFrameCallback((_){
      timer.startCountDown(CountDownMode.action,(){
        currentTask.clear();
        Get.until((route) => route.isFirst);
      });
    });
  }

  _title(){
    return Container(
        margin: EdgeInsets.only(top: 10.h,left: 8.w,right: 8.w,bottom: 10.h),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            InkWell(
              onTap: (){
                currentTask.clear();
                timer.cancel();
                Get.back();
              },
              child: Image.asset("assets/images/back.png", width: 40.w, fit: BoxFit.fitWidth,),
            ),
            Text("办证",style: TextStyle(color: Colors.white,fontSize: 12.sp,fontWeight: FontWeight.bold),),
            Obx(() => Text("${timer.actionTime.value}",style: TextStyle(color: Colors.white,fontSize: 8.sp),))
          ],
        )
    );
  }

  _container(){
    return Container(
        decoration:BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(4.r)),
        ),
        margin: EdgeInsets.only(left: 20.w,right: 20.w,top: 20.h),
        padding: EdgeInsets.only(left: 16.w,right: 16.w,top: 12.h,bottom: 6.h),
        width: double.infinity,
        height: 540.h,
        child: Stack(
          alignment: AlignmentDirectional.center,
          children: [
            Positioned(
              top: 0,
              child: Text('办证须知',style: TextStyle(color: Colors.black,fontSize: 12.sp,fontWeight: FontWeight.bold),),
            ),

            SizedBox(height: 16.h,),
            Positioned(
              top: 36.h,
              left: 0,
              child: Image.asset("assets/images/tip.png",width: 200.w, fit: BoxFit.fitWidth,),
            ),
            Positioned(
              bottom: 20.h,
              child: InkWell(
                onTap: (){
                  Get.to(()=>const Register());
                },
                child: Image.asset("assets/images/know.png",width: 100.w, fit: BoxFit.fitWidth,),
              )
            ),

          ],
        ),
    );
  }

  _step(){
    return Align(child: Image.asset("assets/images/auth_step2.png",height:46.h,fit: BoxFit.fitHeight,));
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton:floatButton(),
      floatingActionButtonLocation:CustomFloatingActionButtonLocation(
          FloatingActionButtonLocation.endFloat, 0,-60.h),
      body: Container(
        width: double.infinity,
        height: double.infinity,
        decoration: const BoxDecoration(
          image: DecorationImage(
            fit: BoxFit.fill,
            image: AssetImage(
              "assets/images/bg.png",
            ),
          ),
        ),
        child: Column(
          children: [
            appBar(),
            _title(),
            _step(),
            _container()
          ],
        ),
      ),
    );
  }
}

